﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class states_rainstate : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        String sResult = "0";
        String sResultValue = "err";
        String sAction = Request.QueryString["act"];
        
        if (sAction != null && sAction.Length > 0)
        {
            if (sAction == "get")
            {
                sResult = "1";
                sResultValue = Convert.ToString(Convert.ToInt16(StaticModel.GetRainState()));
            }
            else if (sAction == "set")
            {
                String sReqValue = Request.QueryString["value"];
                if (sReqValue != null && sReqValue.Length > 0)
                {
                    if (sReqValue.ToLower() == "false" || sReqValue.ToLower() == "true" ||
                        sReqValue.ToLower() == "0" || sReqValue.ToLower() == "1")
                    {
                        sResult = "1";
                        StaticModel.SetRainState(Convert.ToBoolean(sReqValue));
                        sResultValue = Convert.ToString(Convert.ToInt16(StaticModel.GetRainState()));
                    }
                    else
                        sResultValue = "err1";
                }
            }
        }

        Response.Write(sResult + "," + sResultValue);

    }
}